params["_target","_unit","_id"];

if(typeOf cursorTarget == "MapBoard_altis_F")then
{
	_target = cursorTarget;
};

//防止短时间重复执行5s
if(time < as_view_map_time + 10) exitWith{};
as_view_map_time = time;



//这个函数可是客户端执行的
if(_target getVariable ["viewed", true]) exitWith
{
/*
	if!(isNil "as_map_viewed_y") then
	{
		[_unit, format["Gavras上校躲藏在地图网格[%1, %2]！", floor(as_map_viewed_x / 100), floor(as_map_viewed_y / 100)]] remoteExec ["sideChat", 0];
	}
	else
	{
		if!(isNil "as_map_viewed_x") then
		{
			[_unit, format["Gavras上校躲藏在地图网格[%1, %2]！", floor(as_map_viewed_x / 100), "???"]] remoteExec ["sideChat", 0];
		};
	};
	*/
	//[_unit, format[localize "STR_TAG_O_1", floor((as_end_pos select 0) / 100), floor((as_end_pos select 1) / 100)]] remoteExec ["sideChat", 0];
	_unit remoteExec ["fnc_viewMap", 0];
};



as_map_viewed = true;
publicVariable "as_map_viewed";


waitUntil{!isNil "as_show_pos"};

_unit remoteExec ["fnc_viewMap", 0];
//[_unit, format[localize "STR_TAG_O_1", floor((as_end_pos select 0) / 100), floor((as_end_pos select 1) / 100)]] remoteExec ["sideChat", 0];

/*
if(isNil "as_map_viewed_x") then
{
	as_map_viewed_x = as_end_pos select 0;
	publicVariable "as_map_viewed_x";
	[_unit, format["Gavras上校躲藏在地图网格[%1, %2]！", floor(as_map_viewed_x / 100), "???"]] remoteExec ["sideChat", 0];
}
else
{
	if(isNil "as_map_viewed_y") then
	{
		as_map_viewed_y = as_end_pos select 1;
		publicVariable "as_map_viewed_y";
	};
	[_unit, format["Gavras上校躲藏在地图网格[%1, %2]！", floor(as_map_viewed_x / 100), floor(as_map_viewed_y / 100)]] remoteExec ["sideChat", 0];
};
*/

_target setVariable ["viewed", true, true];

